﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace shop.entity
{
    public class JsonResult<T>
    {
        public int ErrorCode { get; set; }
        public string Message { get; set; }
       public T Data { get; set; }

        public static JsonResult<object> RenderError(int errorCode, string message) {
            return new JsonResult<object>() {
                ErrorCode = errorCode,
                Message = message
            };
        }

        public static JsonResult<T> RenderSuccess(T data)
        {
            return new JsonResult<T>()
            {
                ErrorCode = 0,
                Data = data
            };
        }
        public static JsonResult<T> RenderSuccessMessage(string msg)
        {
            return new JsonResult<T>()
            {
                ErrorCode = 0,
                Message = msg
            };
        }
    }
}